namespace Asmex.FileViewer
{
    using System;
    using System.IO;

    public class StorageSigAndHeader : Region
    {
        private ushort _MajorVersion;
        private ushort _MinorVersion;
        private ushort _NumOfStreams;
        private string _VersionString;

        public StorageSigAndHeader(BinaryReader reader)
        {
            base.Start = reader.BaseStream.Position;
            if (reader.ReadUInt32() != 0x424a5342)
            {
                throw new ModException("MetaData:  Incorrect signature.");
            }
            this._MajorVersion = reader.ReadUInt16();
            this._MinorVersion = reader.ReadUInt16();
            reader.ReadUInt32();
            uint num2 = reader.ReadUInt32();
            for (int i = 0; i < num2; i++)
            {
                this._VersionString = this._VersionString + ((char) reader.ReadByte());
            }
            if ((num2 % 4) != 0)
            {
                Stream baseStream = reader.BaseStream;
                baseStream.Position += 4 - (num2 % 4);
            }
            reader.ReadByte();
            reader.ReadByte();
            this._NumOfStreams = reader.ReadUInt16();
            base.Length = reader.BaseStream.Position - base.Start;
        }

        public ushort MajorVersion
        {
            get
            {
                return this._MajorVersion;
            }
        }

        public ushort MinorVersion
        {
            get
            {
                return this._MinorVersion;
            }
        }

        public ushort NumOfStreams
        {
            get
            {
                return this._NumOfStreams;
            }
        }

        public string VersionString
        {
            get
            {
                return this._VersionString;
            }
        }
    }
}
